package com.xihua.sx.controller;


import com.xihua.sx.pojo.CarInfo;
import com.xihua.sx.pojo.PageData;
import com.xihua.sx.service.CarInfoService;
import com.xihua.sx.utils.ResponseMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/car_info")
public class CarInfoController {
    @Autowired
    private CarInfoService carInfoService;
    //get请求
//    @GetMapping("/carInfoById")
//    public ResponseMessage carInfoById(@PathVariable Integer carId){
//        return carInfoService.carInfoById(carId);
//    }
    @GetMapping("/carInfoById")
    public ResponseMessage carInfoById(Integer carId){
        return carInfoService.carInfoById(carId);
    }

    @GetMapping("/carInfoByCode")
    public ResponseMessage carInfoByCode(CarInfo carInfo){
        return carInfoService.carInfoByCode(carInfo);
    }

    @GetMapping("/carInfoAll")
    public ResponseMessage carInfoAll(PageData pageData){        return carInfoService.carInfoAll(pageData);  }

    @RequestMapping(value = "/carInfoDele/{carId}",method = RequestMethod.DELETE)
    public ResponseMessage carInfoDele(@PathVariable Integer carId){
        return carInfoService.carInfoDele(carId);
    }
    //RequestBody请求JSON格式数据
    @PostMapping("/carInfoInsert")
    public ResponseMessage carInfoInsert(@RequestBody CarInfo carInfo){
        System.out.println(carInfo.toString());
        return carInfoService.carInfoInsert(carInfo);
    }
    @PostMapping("/carInfoUpdate")
    public ResponseMessage carInfoUpdate(@RequestBody CarInfo carInfo){
        return carInfoService.carInfoUpdate(carInfo);
    }

}
